home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / qbscrgen.zip / SGDEMO.BAS next >
BASIC Source File  |  1987-07-24  |  26KB  |  919 lines

  1. rem $linesize:132
  2. rem $title:'* Screen I/O Generator *'
  3. rem $subtitle:'* Introduction *'
  4. rem $include:'aecommon.bas'
  5. '
  6. '              SGDEMO
  7. '
  8. '     (c) Roy Barrow, 1986,1987.
  9. '
  10.     dim fl$(255%),dl.2$(4%)                   ' File array, 2nd Key Select Array
  11.     dim text$(24%),datfrm$(3%)                ' Lines 2-24
  12.     dim ip.frame%(24%,80%)                    ' Frame for input markers
  13.     dim var.type$(6%)                         ' Variable types
  14.     dim io.name$(100%)                        ' 100 Names for Input Definition
  15.     dim io.x%(100%)                           ' 100 X Locations
  16.     dim io.y%(100%)                           ' 100 Y Locations
  17.     dim mrec%(100%)                           ' 100 Master Pointers
  18.     dim basgen$(100%)                         ' Basic Generation Sequence Array
  19.     def fnn$(a%)=mid$(str$(a%),2%)            ' Commonly used STRIPPER
  20.  
  21.     data "Single String","Text Block","Date"
  22.     data "Integer","Single Precision","Double Precision"
  23.     data "mm/dd/yy","yy/mm/dd","dd/mm/yy"
  24.     for j%=1% to 6%
  25.         read var.type$(j%)
  26.     next j%
  27.     for j%=1% to 3%
  28.         read datfrm$(j%)
  29.     next j%
  30.  
  31.     call color.init("appcolor.ctl")
  32.  
  33. menu1:
  34.     data 6,"File","Edit","Draw","Input","Exit","Color Setup"
  35.     data 7,"Load","Save","Merge","","Generate Basic","","Status"
  36.     data 9,"Copy of above line","Center Line","Insert Blank Line","Delete Line","Insert Column","Delete Column","Find & Replace","","Clear"
  37.     data 3,"Box","Vertical Line","Horizontal Line"
  38.     data 4,"Definition","","Remove","Clear"
  39.     data 3,"To Editor (ESC)","To Shell","To System"
  40.     data 1,"Define Attributes"
  41.     restore menu1
  42.     gosub get.menu
  43.  
  44. '
  45. '  The menu definition is now made. Now call the Introductory box
  46. '
  47.     locate ,,0
  48.     call qbtools.frame
  49.     w$=input$(1%)
  50.     cls
  51.  
  52.     ae.sstack%=2000%
  53.     call Centre.Text("Screen Generator Version: SGDEMO v 1.02",1%)
  54.     call startup
  55.  
  56.     for j%=1% to 24%
  57.         text$(j%)=string$(80%,32%)
  58.         for k%=1% to 80%
  59.             ip.frame%(j%,k%)=0%
  60.         next k%
  61.     next j%
  62.  
  63.     for j%=1% to 100%
  64.         io.name$(j%)=""
  65.         io.x%(j%)=0%
  66.         io.y%(j%)=0%
  67.         mrec%(j%)=0%
  68.     next j%
  69.  
  70.     call scroll(1,2,80,24,0)
  71.     ins$="Off"
  72.     x%=1%
  73.     y%=2%
  74.     xmin%=1%
  75.     xmax%=80%
  76.     ymin%=2%
  77.     ymax%=24%
  78.     cycle%=0%
  79.     lsch%=32%                      ' Last special alternate character
  80.     dr.only%=0%                    ' Currently in NODRAW mode
  81.     while cycle%=0%
  82.  
  83.         if ip.frame%(y%,x%) then
  84.             i.o.txt$="F5=I/O "
  85.             i.o.set%=1%
  86.         else
  87.             i.o.txt$="         "
  88.             i.o.set%=0%
  89.         end if
  90.  
  91.         if dr.only%=1% then
  92.             i.o.txt$="Draw:"
  93.             if vl.draw%=1% then
  94.                 i.o.txt$=i.o.txt$+"Vl"
  95.             end if
  96.             if hz.draw%=1% then
  97.                 i.o.txt$=i.o.txt$+"Hl"
  98.             end if
  99.             if bx.draw%=1% then
  100.                 i.o.txt$=i.o.txt$+"Box"
  101.             end if
  102.         end if
  103.  
  104.         optex$="F1=Menu  F2=Last Menu  F3=Alt Ch  F4=Last Alt Ch  Ins="+ins$+"  x="+fnn$(x%)+"  y="+fnn$(y%)+"  "+i.o.txt$
  105.         call qprint(optex$,25,1)
  106.         locate y%,x%,1%,0%,15%                             ' Display the cursor
  107.         call Get.Single(ch%,ctype%)
  108.  
  109.         if dr.only%=0% then
  110.             if ctype%=2% then
  111.                 if ch%=61% then
  112.                     for j%=1% to 70%
  113.                         fl$(j%)=chr$(j%+173%)
  114.                     next j%
  115.                     dialog$(1)="Select a"
  116.                     dialog$(2)="Character"
  117.                     dialog$(3)="From List"
  118.                     dialog$(4)=""
  119.                     call select.box(fl$(),8%,70%,1%,opt$)
  120.                     ch%=asc(opt$)
  121.                     lsch%=ch%
  122.                     ctype%=1%
  123.                 end if
  124.             end if
  125.  
  126.             if ctype%=2% then                ' Repeat last Alternate Character
  127.                 if ch%=62% then
  128.                     ch%=lsch%
  129.                     ctype%=1%
  130.                 end if
  131.             end if
  132.  
  133.             if ctype%=2% then
  134.                 if ch%=63% then               ' Display i.o.definition
  135.                     if i.o.set% then
  136.                         nav%=ip.frame%(y%,x%)
  137.                         rec%=mrec%(nav%)
  138.                         get #11,rec%
  139.                         vt%=asc(v.type$)
  140.                         varn$=var.des$
  141.                         call ctrl.trim(varn$)
  142.                         dialog$(1%)="Variable: "+varn$+" ("+var.type$(vt%)+")"
  143.                         if vt%=1% then
  144.                             dialog$(2%)=str$(asc(s.len$))+" characters in length."
  145.                         end if
  146.                         if vt%=2% then
  147.                             dialog$(2%)=str$(asc(b.width$))+" characters wide, and"+str$(asc(b.height$))+" lines high."
  148.                         end if
  149.                         if vt%=3% then
  150.                             dialog$(2%)="Which is in the format:"
  151.                             df%=asc(d.form$)
  152.                             dialog$(2%)=dialog$(2%)+datfrm$(df%)+"."
  153.                         end if
  154.                         if (vt%=4% or vt%=6% or vt%=5%) then
  155.                             dialog$(2%)="In value between"
  156.                             dialog$(2%)=dialog$(2%)+str$(cvd(v.min$))+" and"+str$(cvd(v.max$))+"."
  157.                         end if
  158.                         dc%=2%
  159.                         call Press.Any.Key(dc%)
  160.                     end if
  161.                 end if
  162.             end if
  163.  
  164.             if ctype%=2% then
  165.                 if ch%=59% or ch%=60% then
  166.                     if ch%=59% then
  167.                         where%=varptr(ae.screens%(1%))
  168.                         locate ,,0
  169.                         restore menu1
  170.                         gosub get.menu
  171.                         call Pull.Down.Menu
  172.                         prvmen%=menu%
  173.                         prvop%=menop%
  174.                     end if
  175.                     if ch%=60% then
  176.                         menu%=prvmen%
  177.                         menop%=prvop%
  178.                     end if
  179.                     if menu%=1% then
  180.  
  181. rem $subtitle:'Load an existing file.'
  182. rem $page
  183.                         if menop%=1% then       ' Load a file
  184.                             call getfiles(fl$(),"?","scr",count%)
  185.                             if count%>0% then
  186.                                 call qsort(fl$(),count%)
  187.                                 dialog$(1)="Select file to load"
  188.                                 dialog$(2)="from the list on the"
  189.                                 dialog$(3)="left."
  190.                                 dialog$(4)=""
  191.                                 call select.box(fl$(),10%,count%,12%,opt$)
  192.                                 call ctrl.trim(opt$)
  193.                                 if len(opt$) then
  194.                                     open "r",1,opt$,80
  195.                                     opt$=left$(opt$,instr(opt$,".")-1%)
  196.                                     field #1,80 as s1$
  197.                                     for j%=1% to 24%
  198.                                         get #1,j%
  199.                                         text$(j%)=s1$
  200.                                     next j%
  201.                                     close 1
  202.                                     for j%=2% to 24%
  203.                                         call qprint(text$(j%),j%,1%)
  204.                                     next j%
  205.                                 end if
  206.                             end if
  207.                             if count%=0% then      ' No file exists.
  208.                             end if
  209.                         end if
  210.  
  211. rem $subtitle:'Save a file.'
  212. rem $page
  213.                         if menop%=2% then       ' Save a file
  214.                             dialog$(1)="Save this file as ..."
  215.                             dialog$(2)=""
  216.                             fil.1$=string$(8%,32%)
  217.                             l1%=8%
  218.                             call Dialog(fil.1$,l1%)
  219.                             call ctrl.trim(fil.1$)
  220.                             if len(fil.1$) then
  221.                                 open "r",1,fil.1$+".SCR",80
  222.                                 field #1,80 as s1$
  223.                                 for j%=1% to 24%
  224.                                     lset s1$=text$(j%)
  225.                                     put #1,j%
  226.                                 next j%
  227.                                 close 1
  228.  
  229.                             end if
  230.                         end if
  231.  
  232. rem $subtitle:'Merge a file.'
  233. rem $page
  234.                         if menop%=3% then       ' Merge a file
  235.                             call getfiles(fl$(),"?","scr",count%)
  236.                             if count% then
  237.                                 call qsort(fl$(),count%)
  238.                             end if
  239.                             if count% then
  240.                                 dialog$(1)="Select file to merge from"
  241.                                 dialog$(2)="the list on the left. This"
  242.                                 dialog$(3)="option merges in screen"
  243.                                 dialog$(4)="text only. I/O is ignored."
  244.                                 call select.box(fl$(),10%,count%,12%,opt$)
  245.                                 call ctrl.trim(opt$)
  246.                                 if len(opt$) then
  247.                                     open "r",1,opt$,80
  248.                                     opt$=left$(opt$,instr(opt$,".")-1%)
  249.                                     field #1,80 as s1$
  250.                                     for j%=2% to 24%
  251.                                         get #1,j%
  252.                                         for k%=1% to 80%
  253.                                             if mid$(text$(j%),k%,1%)=" " then
  254.                                                 mid$(text$(j%),k%,1%)=mid$(s1$,k%,1%)
  255.                                             end if
  256.                                         next k%
  257.                                     next j%
  258.                                     close 1
  259.                                     for j%=2% to 24%
  260.                                         call qprint(text$(j%),j%,1%)
  261.                                     next j%
  262.                                 end if
  263.                             end if
  264.                         end if
  265.  
  266. rem $subtitle:'Generate the BASIC code.'
  267. rem $page
  268.                         if menop%=5% then       ' Generate Basic
  269.                             dialog$(1)="BASIC program to create is ..."
  270.                             dialog$(2)=""
  271.                             fil.1$=string$(8%,32%)
  272.                             l1%=8%
  273.                             call Dialog(fil.1$,l1%)
  274.                             call ctrl.trim(fil.1$)
  275.                             open "o",1,fil.1$+".bas"
  276.                             dialog$(1%)="Title this program ..."
  277.                             dialog$(2%)=""
  278.                             call Dialog(tit$,50%)
  279.                             call ctrl.trim(tit$)
  280.                             print #1,"rem $linesize:132"
  281.                             print #1,"rem $title:'"+tit$+"'"
  282.                             print #1,"rem $subtitle:'(c) Copyright Roy Barrow 1986,1987.'"
  283.                             print #1,""
  284.                             print #1,"' Screen Generator Version: SGDEMO"
  285.                             print #1,"' This program ("+fil.1$+") created on: "+date$+", "+time$
  286.                             print #1,""
  287.                             print #1,"  call "+fil.1$+".frame"
  288.                             print #1,""
  289.                             print #1,"  END"
  290.                             print #1,""
  291.                             print #1,"  sub "+fil.1$+".frame static"
  292.                             for j%=2% to 24%
  293.                                 w$=text$(j%)
  294.                                 call trim(w$)
  295.                                 if len(w$) then
  296.                                     w%=instr(text$(j%